#include <stdio.h>
#include <stdlib.h>

struct List
{
    /* data */
    int *list;
    int size;
};
struct List * new_list()
{
    struct List list;
    list.list = malloc(sizeof(int));
    list.list[1] = 0;
    list.size = 1;
    return &list;
}

int list_append(struct List *list, int x)
{
    struct List *chache = (struct List *)realloc(list->list, list->size + 1);
    if (chache == NULL)
    {
        return -1;
        /* code */
    }
    list = chache;
    list->size += 1;
    list->list[list->size - 1] = x;
}

int list_get(struct List *list, int index)
{

    if (index < 0 || index > list->size - 1)
    {
        return -1;
        /* code */
    }
    return list->list[index];
}

int list_set(struct List *list, int index, int value)
{
    if (index < 0 || index > list->size - 1)
    {
        return -1;
        /* code */
    }
    list->list[index] = value;
    return 0;
}

int main(int argc, char const *argv[])
{
    struct List * l = new_list();
    list_append(l,1);
    list_append(l,3);
    list_append(l,5);
    for (int i = 0; i < l->size; i++)
    {
        printf("List[%d] = %d",i,list_get(l,i));
    }
    
    return 0;
}
